﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MedicalLog.WebUI.Controllers.EmergencyFormController+EmergencyFormViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Add Emergency Form
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="header">
        <h4>Registrar un paciente en emergencias</h4>
    </div>
    <div class="main">
    <% using (Html.BeginForm(FormMethod.Post))
       { %>
       <%= Html.ValidationSummary() %>
       <fieldset class="main-style">
            <table style="width: 100%;">
                <tr>
                    <td>Nombre: </td>
                    <td> <%= Model.patient.Name %><%: Html.HiddenFor(x => x.patient.Name) %><%: Html.HiddenFor(x => x.patient.Id) %></td>
                    <td> Apellido</td>
                    <td><%= Model.patient.LastName %><%: Html.HiddenFor(x => x.patient.LastName) %></td>
                </tr>
                <tr>
                    <td>Teléfono:</td>
                    <td><%=Model.patient.Telephone %><%: Html.HiddenFor(x => x.patient.Telephone) %></td>
                    <td>Celular:</td>
                    <td><%=Model.patient.Celphone %><%: Html.HiddenFor(x => x.patient.Celphone) %></td>
                </tr>
                <tr>
                    <td class="editor-label">
                        Dirección:
                    </td>
                    <td class="editor-field" colspan="3">
                        <%= Model.patient.Address %>
                        <%: Html.HiddenFor(x => x.patient.Address) %>
                    </td>
                </tr>
                <tr>
                    <td>Doctor:</td>
                    <td>
                        <%: Html.DropDownListFor(x => x.doctor.IdDoctor, ViewData["DoctorInformation"] as IEnumerable<SelectListItem>) %>
                    </td>
                    <td>Fecha:</td>
                    <td><%= DateTime.Now.ToString("dd/MM/yyyy hh:mm") %></td>
                </tr>
            </table>
       </fieldset>
       <h5>Información General</h5>
       <fieldset class="main-style">
            <table>
                <tr>
                    <td>Alergias:</td>
                    <td><%= Html.TextBoxFor(x => x.emergencyForm.Allergies, new {size="70"}) %></td>
                </tr>
                <tr>
                    <td>Historia Social:</td>
                    <td><%=Html.TextBoxFor(x => x.emergencyForm.SocialHistory, new { size = "70" })%></td>
                </tr>
                 <tr>
                    <td>Revisión por Sistemas:</td>
                    <td><%=Html.TextAreaFor(x => x.emergencyForm.SystemRevision, new { cols = "70", rows = "5" })%></td>
                </tr>
                <tr>
                    <td>Examen Físico:</td>
                    <td><%= Html.TextAreaFor(x => x.emergencyForm.PhysicalTest, new { cols = "70", rows = "5" })%></td>
                </tr>
                <tr>
                    <td>Historia enfermedad actual:</td>
                    <td><%= Html.TextAreaFor(x => x.emergencyForm.HistoryActualDisease, new { cols = "70", rows = "5" })%></td>
                </tr>
                <tr>
                    <td>Tratamiento:</td>
                    <td><%= Html.TextAreaFor(x => x.emergencyForm.Treatment, new { cols = "70", rows = "3" })%></td>
                </tr>
            </table>
       </fieldset>
       <h5>Signos Vitales</h5>
       <fieldset class="main-style">
            <table>
                <tr>
                    <td colspan="2">
                        <div>
                            <table style="width: 100%;">
                                <thead>
                                    <tr>
                                        <th style="width: 12%">Hora</th>
                                        <th style="width: 12%">TA</th>
                                        <th style="width: 12%">FC</th>
                                        <th style="width: 12%">FR</th>
                                        <th style="width: 12%">Temp</th>
                                        <th style="width: 12%">Sat O2</th>
                                        <th style="width: 12%">Glic.</th>
                                        <th style="width: 12%"></th>
                                    </tr>
                                </thead>
                            </table>
                            <div id="VitalSignFather">
                                <% foreach (var item in Model.VitalSigns)
                                    { %>
                                        <% Html.RenderPartial("VitalSignsViewModel", item); %>
                                    <% } %>
                            </div>
                        </div>
                        <%= Html.ActionLink("Agregar", "AddVitalSign", null, new { @id="addVitalSign" })%>
                    </td>
                </tr>
            </table>
       </fieldset>
       <h5>Laboratorios</h5>
       <fieldset class="main-style">
            <table style="width: 48%; float: left;">
                <tr>
                    <td style="border-right: 1px solid black; text-align: center;">Blanco</td>
                    <td style="border-left: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black; text-align: center;">H+<br /><%= Html.TextBoxFor(x => x.Hplus.Description, new {size="5", @class="dec"}) %></td>
                    <td style="border-left: 1px solid black; text-align: center;">Plaq.</td>
                </tr>
                 <tr>
                    <td style="border-right: 1px solid black; text-align: center;"><%= Html.TextBoxFor(x => x.blanco.Description, new { size = "5", @class = "dec" })%></td>
                    <td style="border-left: 1px solid black; border-right: 1px solid black; text-align: center;">Hg<br /><%=Html.TextBoxFor(x => x.Hg.Description, new { size = "5", @class = "dec" })%></td>
                    <td style="border-left: 1px solid black; text-align: center;"><%= Html.TextBoxFor(x => x.Plaquetas.Description, new { size = "5", @class = "dec" })%></td>
                </tr>
            </table>
            <table style="width: 48%;">
                <tr>
                    <td style="border-right: 1px solid black; border-bottom: 1px solid black; text-align: center;">Sodio<br /><%= Html.TextBoxFor(x => x.Sodio.Description, new { size = "5", @class = "dec" })%></td>
                    <td style="border-left: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black; text-align: center;">Cloro<br /><%= Html.TextBoxFor(x => x.Cloro.Description, new { size = "5", @class = "dec" })%></td>
                    <td style="border-left: 1px solid black; border-right: 1px solid black; border-bottom: 1px solid black; text-align: center;">Bun<br /><%= Html.TextBoxFor(x => x.Bun.Description, new { size = "5", @class = "dec" })%></td>
                    <td style="text-align: center; border-left: 1px solid black;">Gluc.</td>
                </tr>
                 <tr>
                    <td style="border-right: 1px solid black; text-align: center;">Potasio<br /><%= Html.TextBoxFor(x => x.Potasio.Description, new { size = "5", @class = "dec" })%></td>
                    <td style="border-left: 1px solid black; border-right: 1px solid black; text-align: center;">Bicar.<br /><%= Html.TextBoxFor(x => x.Bicarbonato.Description, new { size = "5", @class = "dec" })%></td>
                    <td style="border-left: 1px solid black; border-right: 1px solid black; text-align: center;">Creat.<br /><%= Html.TextBoxFor(x => x.Crent.Description, new { size = "5", @class = "dec" })%></td>
                    <td style="text-align: center; border-left: 1px solid black;"><%= Html.TextBoxFor(x => x.Glucemia.Description, new { size = "5", @class = "dec" })%></td>
                </tr>
            </table>
            <br />
            <table>
                <tr>
                    <td>Troponina:</td>
                    <td><%= Html.TextBoxFor(x => x.Troponimia.Description, new { size = "5", @class = "dec" })%></td>
                    <td>CK MB:</td>
                    <td><%= Html.TextBoxFor(x => x.CKMB.Description, new { size = "5", @class = "dec" })%></td>
                </tr>
                <tr>
                    <td>CPK:</td>
                    <td><%= Html.TextBoxFor(x => x.CPK.Description, new { size = "5", @class = "dec" })%></td>
                    <td>Urinalisis:</td>
                    <td><%= Html.TextBoxFor(x => x.Urinalisis.Description, new { size = "5", @class = "dec" })%></td>
                </tr>
                <tr>
                    <td>Otros:</td>
                    <td colspan="3"><%= Html.TextAreaFor(x => x.Otros.Description, new { cols = "70", rows = "3" })%></td>
                </tr>
            </table>
       </fieldset>
       <h5>Diagnóstico</h5>
       <fieldset class="main-style">
            <table>
                <tr>
                    <td>Diagnóstico:</td>
                    <td colspan="3"><%=Html.TextAreaFor(x => x.emergencyForm.Diagnostic, new { cols = "70", rows = "5", id = "DiagnosticArea" }) %></td>
                </tr>
                <tr id="suggestionContainer" style="display: none;">
                    <td></td>
                    <td colspan="3" class="suggestionBoxContainer"></td>
                </tr>
                <tr>
                    <td>Disposición:</td>
                    <td>
                        <input name="Disposition" type="radio" value="1" checked="checked" />Ingreso a Piso&nbsp;&nbsp;
                        <input name="Disposition" type="radio" value="2" />Alta&nbsp;&nbsp;
                        <input name="Disposition" type="radio" value="3" />Alta a petición&nbsp;&nbsp;
                        <input name="Disposition" type="radio" value="4" />Traslado a Otro Centro
                        <%: Html.HiddenFor(x => x.emergencyForm.Disposition, new { @id = "DispositionValue" })%>
                        <div id="DetailAltaPet" style="display: none; margin-top: 15px;">
                            Nombre Centro: <%: Html.TextBoxFor(x => x.emergencyForm.DispositionDescription, new { @id ="DispDescription"})%>
                        </div>
                    </td>
                </tr>
            </table>
       </fieldset>
       <div class="footer">
        <h4>
            Acciones
        </h4>
        <fieldset class="main-style2">
            <p>
                <input type="submit" value="Agregar formulario" />
            </p>
            <%: Html.ActionLink("Regresar a la página principal", "SearchPatient","Patient") %>
        </fieldset>
    </div>
    <%} %>
    </div>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeaderContent" runat="server">
    <link href="../../Content/jquery-ui-timepicker.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery.ui.timepicker.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/Constraint.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#DispositionValue").val(1);
            $("#addVitalSign").click(function () {
                $.ajax({
                    url: this.href,
                    cache: false,
                    success: function (html) { $("#VitalSignFather").append(html); }
                });
                return false;
            });

            $("a.eliminarFila").live("click", function () {
                $(this).parents("div.editorRow:first").remove();
                return false;
            });

            function DeleteRow(object) {
                $(object).parents("div.editorRow:first")
            }

            $("input[name='disposition']").click(function () {
                $("#DispositionValue").val($(this).val());
                if ($(this).val() == 4) {
                    $("#DetailAltaPet").show('slow');
                    $("#DispDescription").val($(this).html());
                }
                else {
                    $("#DetailAltaPet").hide('slow');
                    $("#DispDescription").val($(this).html());
                }
            });
            $(".dec").numeric({ format: "0.000" });

            $("#DiagnosticArea").keyup(function () {
                if ($("#DiagnosticArea").val().length > 1) {
                    $.ajax({
                        url: '/EmergencyForm/getSuggestions',
                        data: 'pText=' + $("#DiagnosticArea").val(),
                        cache: false,
                        success: function (html) { $(".suggestionBoxContainer").html(html); }
                    });
                    $("#suggestionContainer").show();
                }
                else {
                    $("#suggestionContainer").hide();
                }
            });

            $(".suggestionItem").live("click", function () {
                var txtValue = $(this).html();
                $("#DiagnosticArea").html(txtValue);
                $("#suggestionContainer").hide();
            });
        });
    </script>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
